using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class zTableFieldInfo
    {
		#region Local Variable
		private Int32 _TableFieldID;
		public Int32 TableFieldID
		{
			get { return _TableFieldID; }
			set { _TableFieldID = value; }
		}
		private String _TableName;
		public String TableName
		{
			get { return _TableName; }
			set { _TableName = value; }
		}
		private String _FieldName;
		public String FieldName
		{
			get { return _FieldName; }
			set { _FieldName = value; }
		}
		private String _FormName;
		public String FormName
		{
			get { return _FormName; }
			set { _FormName = value; }
		}
		private String _FormCaption;
		public String FormCaption
		{
			get { return _FormCaption; }
			set { _FormCaption = value; }
		}
		private String _BoxName;
		public String BoxName
		{
			get { return _BoxName; }
			set { _BoxName = value; }
		}
		private String _LabelName;
		public String LabelName
		{
			get { return _LabelName; }
			set { _LabelName = value; }
		}
		private String _LabelCaption;
		public String LabelCaption
		{
			get { return _LabelCaption; }
			set { _LabelCaption = value; }
		}
		private String _SourceName;
		public String SourceName
		{
			get { return _SourceName; }
			set { _SourceName = value; }
		}
		private String _Description1;
		public String Description1
		{
			get { return _Description1; }
			set { _Description1 = value; }
		}
		private String _Filter;
		public String Filter
		{
			get { return _Filter; }
			set { _Filter = value; }
		}
		private String _RuleSet;
		public String RuleSet
		{
			get { return _RuleSet; }
			set { _RuleSet = value; }
		}
		private String _Security;
		public String Security
		{
			get { return _Security; }
			set { _Security = value; }
		}
		private String _BoxType;
		public String BoxType
		{
			get { return _BoxType; }
			set { _BoxType = value; }
		}
		private String _Validated;
		public String Validated
		{
			get { return _Validated; }
			set { _Validated = value; }
		}
		private String _SetRowsource;
		public String SetRowsource
		{
			get { return _SetRowsource; }
			set { _SetRowsource = value; }
		}
        #endregion LocalVariable
        
        #region Constructor
		public zTableFieldInfo()
		{
			_TableFieldID = -1;
			_TableName = "";
			_FieldName = "";
			_FormName = "";
			_FormCaption = "";
			_BoxName = "";
			_LabelName = "";
			_LabelCaption = "";
			_SourceName = "";
			_Description1 = "";
			_Filter = "";
			_RuleSet = "";
			_Security = "";
			_BoxType = "";
			_Validated = "";
			_SetRowsource = "";
		}
		public zTableFieldInfo(
			Int32 TableFieldID,
			String TableName,
			String FieldName,
			String FormName,
			String FormCaption,
			String BoxName,
			String LabelName,
			String LabelCaption,
			String SourceName,
			String Description1,
			String Filter,
			String RuleSet,
			String Security,
			String BoxType,
			String Validated,
			String SetRowsource
			)
		{
			_TableFieldID = TableFieldID;
			_TableName = TableName;
			_FieldName = FieldName;
			_FormName = FormName;
			_FormCaption = FormCaption;
			_BoxName = BoxName;
			_LabelName = LabelName;
			_LabelCaption = LabelCaption;
			_SourceName = SourceName;
			_Description1 = Description1;
			_Filter = Filter;
			_RuleSet = RuleSet;
			_Security = Security;
			_BoxType = BoxType;
			_Validated = Validated;
			_SetRowsource = SetRowsource;
		}
		public zTableFieldInfo(DataRow dr)
		{
			if (dr != null)
			{
				_TableFieldID = dr["TableFieldID"] == DBNull.Value ? -1 : (Int32)dr["TableFieldID"];
				_TableName = dr["TableName"] == DBNull.Value ? "" : (String)dr["TableName"];
				_FieldName = dr["FieldName"] == DBNull.Value ? "" : (String)dr["FieldName"];
				_FormName = dr["FormName"] == DBNull.Value ? "" : (String)dr["FormName"];
				_FormCaption = dr["FormCaption"] == DBNull.Value ? "" : (String)dr["FormCaption"];
				_BoxName = dr["BoxName"] == DBNull.Value ? "" : (String)dr["BoxName"];
				_LabelName = dr["LabelName"] == DBNull.Value ? "" : (String)dr["LabelName"];
				_LabelCaption = dr["LabelCaption"] == DBNull.Value ? "" : (String)dr["LabelCaption"];
				_SourceName = dr["SourceName"] == DBNull.Value ? "" : (String)dr["SourceName"];
				_Description1 = dr["Description1"] == DBNull.Value ? "" : (String)dr["Description1"];
				_Filter = dr["Filter"] == DBNull.Value ? "" : (String)dr["Filter"];
				_RuleSet = dr["RuleSet"] == DBNull.Value ? "" : (String)dr["RuleSet"];
				_Security = dr["Security"] == DBNull.Value ? "" : (String)dr["Security"];
				_BoxType = dr["BoxType"] == DBNull.Value ? "" : (String)dr["BoxType"];
				_Validated = dr["Validated"] == DBNull.Value ? "" : (String)dr["Validated"];
				_SetRowsource = dr["SetRowsource"] == DBNull.Value ? "" : (String)dr["SetRowsource"];
			}
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TblzTableField");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn("TableFieldID", typeof(Int32)),
				new DataColumn("TableName", typeof(String)),
				new DataColumn("FieldName", typeof(String)),
				new DataColumn("FormName", typeof(String)),
				new DataColumn("FormCaption", typeof(String)),
				new DataColumn("BoxName", typeof(String)),
				new DataColumn("LabelName", typeof(String)),
				new DataColumn("LabelCaption", typeof(String)),
				new DataColumn("SourceName", typeof(String)),
				new DataColumn("Description1", typeof(String)),
				new DataColumn("Filter", typeof(String)),
				new DataColumn("RuleSet", typeof(String)),
				new DataColumn("Security", typeof(String)),
				new DataColumn("BoxType", typeof(String)),
				new DataColumn("Validated", typeof(String)),
				new DataColumn("SetRowsource", typeof(String))
				});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row["TableFieldID"] = _TableFieldID;
			row["TableName"] = _TableName;
			row["FieldName"] = _FieldName;
			row["FormName"] = _FormName;
			row["FormCaption"] = _FormCaption;
			row["BoxName"] = _BoxName;
			row["LabelName"] = _LabelName;
			row["LabelCaption"] = _LabelCaption;
			row["SourceName"] = _SourceName;
			row["Description1"] = _Description1;
			row["Filter"] = _Filter;
			row["RuleSet"] = _RuleSet;
			row["Security"] = _Security;
			row["BoxType"] = _BoxType;
			row["Validated"] = _Validated;
			row["SetRowsource"] = _SetRowsource;
			return row;
		}
        #endregion InitTable
    }
}
